package com.byq.mm.foundation.cluster.datatype;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

public class IntListValue implements AttributeValue {
	List<Integer> value = new ArrayList<Integer>();
	public IntListValue(List<Integer> list) {
		value = list;
	}
	public IntListValue() {
	}
	@Override
	public void decode(String s) {
		String[] ss = s.split("divider-byq");
		for(String d : ss){
			try {
				d = URLDecoder.decode(d, "UTF-8");
				value.add(Integer.parseInt(d));
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}
	public List<Integer> getValue(){
		return value;
	}
	@Override
	public String encode() {
		String rst = null;
		for(int s : value){
			
			if(rst == null)
				rst = s + "";
			else rst += ("divider-byq" + s);
		}
		return rst;
	}

}
